package com.gljx.web.controller;

import com.gljx.util.CommonUtil;
import com.gljx.web.service.CommonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;

@Controller
@RequestMapping("/common")
public class CommonAction {

	@Autowired
	private CommonService commonService;
	
	@RequestMapping("/company.action")
	@ResponseBody
	public Map<String, Object> company(String rows,
									   String page,
									   String company        //公司
			 					, HttpServletRequest request){
		if(CommonUtil.isSpecialChar_strict(company)){
			Map <String,Object > dataMap = new HashMap<String, Object>();
			dataMap.put("error", "非法字符");
			return dataMap;
		}
		request.getSession().setAttribute("loadingFlag",1);
		return commonService.selectCompanyPage(rows, page, company);
	}
	
	@RequestMapping("/dept.action")
	@ResponseBody
	public Map<String, Object> dept(String rows,
									 String page,
									 String dept,		//部门
									 String companyLongFnumber//公司长编码
									 ){
		if(CommonUtil.isSpecialChar_simple_deletStr(new String[]{"!"},dept,companyLongFnumber)){
			Map <String,Object > dataMap = new HashMap<String, Object>();
			dataMap.put("error", "非法字符");
			return dataMap;
		}
		return commonService.selectDept(rows, page,dept, companyLongFnumber);
	}
}
